<template>
  <div>
    <Carousel
      @on-click="previewFun"
      v-if="adList.length"
      class="ad-content"
      :autoplay="adList.length == 1 ? false : true"
      loop
      radius-dot
      :autoplay-speed="5000"
      :arrow="'never'"
      style="cursor: pointer; z-index: 999">
      <CarouselItem v-for="(item, index) in adList" :key="index" style="max-height: 60px">
        <img :src="item.pcImgUrl" style="width: 100%" :data-id="item.id" />
      </CarouselItem>
    </Carousel>
    <!--预览-->
    <preview ref="preview"></preview>
  </div>
</template>
<script>
  import adMgr from '@/biz/backStage/advertisement'
  import preview from '@/views/backStage/advertisement/components/preview.vue'
  export default {
    data() {
      return {
        adList: []
      }
    },
    props: {
      orgId: {
        type: [Number, String]
      }
    },
    components: {
      preview
    },
    computed: {},
    activated() {},
    watch: {},
    methods: {
      previewFun(index) {
        let item = this.adList[index]
        item.orgId = this.orgId == 'null' ? null : this.orgId
        item.roleId = this.$dt.userInfo().role.roleId
        this.$refs.preview.show(item)
      },
      getAdvListByOnShelf() {
        let params = {
          displayType: 2,
          roleId: this.$dt.userInfo().role.roleId
          // orgId: this.orgId == 'null' ? null : this.orgId
        }
        if (this.orgId == 'null' || this.orgId == null) {
        } else {
          params.orgId = this.orgId
        }
        adMgr.getIndexAd(params).then((res) => {
          this.adList = res
        })
      }
    },
    created() {},
    mounted() {}
  }
</script>
<style lang="scss" scoped>
  .ad-content {
    margin-bottom: 1.2%;
    ::v-deep .ivu-carousel-dots li button.radius {
      width: 10px;
      height: 10px;
    }
    ::v-deep .ivu-carousel-dots-inside {
      bottom: 6px;
      width: 100px;
      left: 50%;
      margin-left: -50px;
    }
  }
</style>
